package models;

import init.AppLauncher;

import java.util.ArrayList;

public class ArtistList {
	private static ArtistList instance;
	private ArrayList<Artist>artistList= new ArrayList<Artist>();
	
    public static ArtistList getInstance() {
        if (null == instance) { // Premier appel
            instance = new ArtistList();
        }
        return instance;
    }

	public void setArtistList(ArrayList<Artist> artistList) {
		this.artistList = artistList;
	}

	public ArrayList<Artist> getArtistList() {
		return artistList;
	}
	
	public void addArtist(Artist a){
		artistList.add(a);
		
	}
	
	public Artist getArtistByPGID(String pgid){
		Artist artist=null;
		for(int i=0; i<artistList.size(); i++){
			if(artistList.get(i).getPgid().equals(pgid)){
				artist=artistList.get(i);
			}
		}
		return artist;
	}
	
	public ArrayList<Artist> getArtistListPerMajorStyle(MajorStyle ms){
		ArrayList<Artist>artisMajorStyletList= new ArrayList<Artist>();
		for(int i=0; i<artistList.size(); i++){
			if(artistList.get(i).getSubStyle()!=null && artistList.get(i).getSubStyle().getMajorStyle().equals(ms)){
				artisMajorStyletList.add(artistList.get(i));
			}
		}
		return artisMajorStyletList;
		
	}
	
	public ArrayList<Artist> getArtistListPerMajorStyleActive(MajorStyle ms){
		ArrayList<Artist>artisMajorStyletList= new ArrayList<Artist>();
		for(int i=0; i<artistList.size(); i++){
			if(artistList.get(i).getSubStyle()!=null && artistList.get(i).getSubStyle().getMajorStyle().equals(ms)){
				if(artistList.get(i).getExistence_year_int()>= AppLauncher.filterValue1 && artistList.get(i).getCeased_year_int()<= AppLauncher.filterValue2){
					artisMajorStyletList.add(artistList.get(i));
				}
			}
		}
		return artisMajorStyletList;
		
	}
    
	public Artist getArtistByWindowId(int id){
		Artist artist=null;
		for(int i=0; i<artistList.size(); i++){
			if(artistList.get(i).getWindowId()==id){
				artist=artistList.get(i);
			}
		}
		return artist;
	}

}
